﻿namespace ExamV5.ManagSys
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.IO;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Xml;

    public class ManagSetSys : Page
    {
        protected Button butBak;
        protected Button butDefault;
        protected GridView DataGridInfo;
        protected DropDownList DDLMaxTime;
        protected DropDownList DDLMinTime;
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        protected Label labTip;
        private PublicFun publicFun_0 = new PublicFun();
        protected RadioButtonList RBLAllowPrint;
        protected RadioButtonList RBLBRubricType;
        protected RadioButtonList RBLCRubric;
        protected RadioButtonList RBLDayRubric;
        protected RadioButtonList RBLDRubric;
        protected RadioButtonList RBLGradeLook;
        protected RadioButtonList RBLGradeReport;
        protected RadioButtonList RBLGradeSort;
        protected RadioButtonList RBLGradeStand;
        protected RadioButtonList RBLHomeSet;
        protected RadioButtonList RBLJRubric;
        protected RadioButtonList RBLLookPaperFlag;
        protected RadioButtonList RBLLookTestExam;
        protected RadioButtonList RBLManagGradeType;
        protected RadioButtonList RBLOpertionRubricSet;
        protected RadioButtonList RBLRegCheck;
        protected RadioButtonList RBLRExamPaperType;
        protected RadioButtonList RBLRubricLoop;
        protected RadioButtonList RBLSetReExam;
        protected RadioButtonList RBLStudyOKAn;
        protected RadioButtonList RBLStuEdit;
        protected RadioButtonList RBLSumGradeSort;
        protected RadioButtonList RBLTestPaper;
        protected ScriptManager SM;
        protected TextBox txtDayFen;
        protected TextBox txtRightStudySum;
        protected TextBox txtRubricStudySum;
        protected TextBox txtStudyFen;
        protected TextBox txtSubStrLength;
        protected UpdatePanel UPPart;

        protected void butBak_Click(object sender, EventArgs e)
        {
            if (this.butBak.Text == "开始备份")
            {
                try
                {
                    this.butBak.Text = "正在备份";
                    this.labTip.Text = "&nbsp;&nbsp; &nbsp;&nbsp; 正在备份数据库请稍候...";
                    string str = "";
                    str = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString.ToLower();
                    str = str.Substring(str.IndexOf(";database=") + 10);
                    str = str.Substring(0, str.IndexOf(";uid="));
                    this.butBak.Text = "正在备份";
                    string str2 = "ExamV5Data.bak";
                    string strSql = "BACKUP DATABASE " + str.Trim() + " TO DISK = '" + base.Server.MapPath("../PublicFile/") + str2 + "' WITH FORMAT, NAME = 'Full Backup of " + str.Trim() + "'";
                    this.publicFun_0.ExecuteSql(strSql);
                    this.labTip.Text = "&nbsp;&nbsp; &nbsp;&nbsp; 数据库备份成功！单击【<a href='../FrmDownLoad.aspx?FileName=" + str2 + "' target=_blank><font color=red>下载</font></a>】进行保存";
                    this.butBak.Text = "开始备份";
                }
                catch
                {
                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BBakDataTip", @"alert('备份数据库失败！\n\n请将PublicFile目录设置为Everyone用户可修改权限！')", true);
                }
            }
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        protected void butDefault_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt16(this.txtRightStudySum.Text.Trim()) > Convert.ToInt16(this.txtRubricStudySum.Text.Trim()))
            {
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheckTIPA", "alert('在线练习答对数超过练习题总数！')", true);
            }
            else
            {
                string str = "";
                string str5 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsTestPaper'", "ParmValue").Trim();
                string str4 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsCheckDRubric'", "ParmValue").Trim();
                string str2 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsLookTestExam'", "ParmValue").Trim();
                string str6 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsCheckBRubric'", "ParmValue").Trim();
                string str8 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsGradeSort'", "ParmValue").Trim();
                string str7 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsGradeLook'", "ParmValue").Trim();
                string str9 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsSetReExam'", "ParmValue").Trim();
                string str3 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsCheckJRubric'", "ParmValue").Trim();
                string str10 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsRegUserCheck'", "ParmValue").Trim();
                string str11 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsStuEdit'", "ParmValue").Trim();
                string str22 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsGradeStand'", "ParmValue").Trim();
                string str21 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='BRubricType'", "ParmValue").Trim();
                string str20 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='GradeReport'", "ParmValue").Trim();
                string str19 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='RExamPaperType'", "ParmValue").Trim();
                string str12 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='DayRubric'", "ParmValue").Trim();
                string str13 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='StudyFen'", "ParmValue").Trim();
                string str17 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='RightStudy'", "ParmValue").Trim();
                string str14 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='DayFen'", "ParmValue").Trim();
                if (!(this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='RubricLoop'", "ParmValue").Trim().Trim() == ""))
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLRubricLoop.SelectedItem.Value + "' where ParmMemo='RubricLoop';";
                }
                else
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('重复试题提示','" + this.RBLRubricLoop.SelectedItem.Value + "','RubricLoop');";
                }
                if (this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsRubricMemo'", "ParmValue").Trim().Trim() == "")
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('批量导入试题答案说明','" + this.RBLOpertionRubricSet.SelectedItem.Value + "','IsRubricMemo');";
                }
                else
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLOpertionRubricSet.SelectedItem.Value + "' where ParmMemo='IsRubricMemo';";
                }
                if (this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsStudyLookOK'", "ParmValue").Trim().Trim() == "")
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('在线练习查看答案','" + this.RBLStudyOKAn.SelectedItem.Value + "','IsStudyLookOK');";
                }
                else
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLStudyOKAn.SelectedItem.Value + "' where ParmMemo='IsStudyLookOK';";
                }
                if (this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsAllowPrint'", "ParmValue").Trim().Trim() == "")
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('考生自由打印成绩单','" + this.RBLAllowPrint.SelectedItem.Value + "','IsAllowPrint');";
                }
                else
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLAllowPrint.SelectedItem.Value + "' where ParmMemo='IsAllowPrint';";
                }
                if (this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='LookPaperFlag'", "ParmValue").Trim().Trim() == "")
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('考生查看试卷批改明细','" + this.RBLLookPaperFlag.SelectedItem.Value + "','LookPaperFlag');";
                }
                else
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLLookPaperFlag.SelectedItem.Value + "' where ParmMemo='LookPaperFlag';";
                }
                if (!(this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='ManagGradeType'", "ParmValue").Trim().Trim() == ""))
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLManagGradeType.SelectedItem.Value + "' where ParmMemo='ManagGradeType';";
                }
                else
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('考试成绩管理模式设置','" + this.RBLManagGradeType.SelectedItem.Value + "','ManagGradeType');";
                }
                if (!(this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='SumGradeSort'", "ParmValue").Trim().Trim() == ""))
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLSumGradeSort.SelectedItem.Value + "' where ParmMemo='SumGradeSort';";
                }
                else
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('同分用时少排前','" + this.RBLSumGradeSort.SelectedItem.Value + "','SumGradeSort');";
                }
                if (!(str22.Trim() == ""))
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLGradeStand.SelectedItem.Value + "' where ParmMemo='IsGradeStand';";
                }
                else
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('考生历史分值标准显示','" + this.RBLGradeStand.SelectedItem.Value + "','IsGradeStand');";
                }
                if (!(str21.Trim() == ""))
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLBRubricType.SelectedItem.Value + "' where ParmMemo='BRubricType';";
                }
                else
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('多选题可选答案两个以上','" + this.RBLBRubricType.SelectedItem.Value + "','BRubricType');";
                }
                if (!(str20.Trim() == ""))
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLGradeReport.SelectedItem.Value + "' where ParmMemo='GradeReport';";
                }
                else
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('成绩报表平均分应考实考人','" + this.RBLGradeReport.SelectedItem.Value + "','GradeReport');";
                }
                if (str19.Trim() == "")
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('重考生成试卷方式','" + this.RBLRExamPaperType.SelectedItem.Value + "','RExamPaperType');";
                }
                else
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLRExamPaperType.SelectedItem.Value + "' where ParmMemo='RExamPaperType';";
                }
                string str18 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='StudyRubricSum'", "ParmValue").Trim();
                if ((this.txtRubricStudySum.Text.Trim() == "") || (this.txtRubricStudySum.Text.Trim() == "0"))
                {
                    this.txtRubricStudySum.Text = "10";
                }
                if (str18 == "")
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('考生练习默认题数','" + this.txtRubricStudySum.Text.Trim() + "','StudyRubricSum');";
                }
                else
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.txtRubricStudySum.Text.Trim() + "' where ParmMemo='StudyRubricSum';";
                }
                if ((this.txtRightStudySum.Text.Trim() == "") || (this.txtRightStudySum.Text.Trim() == "0"))
                {
                    this.txtRightStudySum.Text = "8";
                }
                if (!(str17 == ""))
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.txtRightStudySum.Text.Trim() + "' where ParmMemo='RightStudy';";
                }
                else
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('考生练习答对题数','" + this.txtRightStudySum.Text.Trim() + "','RightStudy');";
                }
                if (this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='SubStrLength'", "ParmValue").Trim().Trim() == "")
                {
                    this.txtSubStrLength.Text = "20";
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('显示文字过长截取长度','" + this.publicFun_0.CheckString(this.txtSubStrLength.Text) + "','SubStrLength');";
                }
                else
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.publicFun_0.CheckString(this.txtSubStrLength.Text) + "' where ParmMemo='SubStrLength';";
                }
                if (!(this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='HomeSet'", "ParmValue").Trim().Trim() == ""))
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLHomeSet.SelectedItem.Value + "' where ParmMemo='HomeSet';";
                }
                else
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('考生登陆后显示首页为','" + this.RBLHomeSet.SelectedItem.Value + "','HomeSet');";
                }
                if (!(str14.Trim() == ""))
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.publicFun_0.CheckString(this.txtDayFen.Text) + "' where ParmMemo='DayFen';";
                }
                else
                {
                    this.txtDayFen.Text = "1";
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('每日一题得学分值','" + this.publicFun_0.CheckString(this.txtDayFen.Text) + "','DayFen');";
                }
                if (!(str13.Trim() == ""))
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.publicFun_0.CheckString(this.txtStudyFen.Text) + "' where ParmMemo='StudyFen';";
                }
                else
                {
                    this.txtStudyFen.Text = "1";
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('考生练习得学分值','" + this.publicFun_0.CheckString(this.txtStudyFen.Text) + "','StudyFen');";
                }
                if (str12 == "")
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('每日一题开关设置','N','DayRubric');";
                }
                else
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLDayRubric.SelectedItem.Value + "' where ParmMemo='DayRubric';";
                }
                if (str11 == "")
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('考生修改个人资料设置','Y','IsStuEdit');";
                }
                else
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLStuEdit.SelectedItem.Value + "' where ParmMemo='IsStuEdit';";
                }
                if (!(str10 == ""))
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLRegCheck.SelectedItem.Value + "' where ParmMemo='IsRegUserCheck';";
                }
                else
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('用户注册审核设置','" + this.RBLRegCheck.SelectedItem.Value + "','IsRegUserCheck');";
                }
                if (str9 == "")
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('考生自由设置重考','" + this.RBLSetReExam.SelectedItem.Value + "','IsSetReExam');";
                }
                else
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLSetReExam.SelectedItem.Value + "' where ParmMemo='IsSetReExam';";
                }
                if (str8 == "")
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('考生查看自我排名','" + this.RBLGradeSort.SelectedItem.Value + "','IsGradeSort');";
                }
                else
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLGradeSort.SelectedItem.Value + "' where ParmMemo='IsGradeSort';";
                }
                if (!(str7 == ""))
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLGradeLook.SelectedItem.Value + "' where ParmMemo='IsGradeLook';";
                }
                else
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('考生查看自我得分','" + this.RBLGradeLook.SelectedItem.Value + "','IsGradeLook');";
                }
                if (str6 == "")
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('多选题判分标准','" + this.RBLCRubric.SelectedItem.Value + "','IsCheckBRubric');";
                }
                else
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLCRubric.SelectedItem.Value + "' where ParmMemo='IsCheckBRubric';";
                }
                if (str5 == "")
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('自定义模拟试卷','" + this.RBLTestPaper.SelectedItem.Value + "','IsTestPaper');";
                }
                else
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLTestPaper.SelectedItem.Value + "' where ParmMemo='IsTestPaper';";
                }
                if (str4 == "")
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('填空题人工批改','" + this.RBLDRubric.SelectedItem.Value + "','IsCheckDRubric');";
                }
                else
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLDRubric.SelectedItem.Value + "' where ParmMemo='IsCheckDRubric';";
                }
                if (str3 == "")
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('综合题人工批改','" + this.RBLJRubric.SelectedItem.Value + "','IsCheckJRubric');";
                }
                else
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLJRubric.SelectedItem.Value + "' where ParmMemo='IsCheckJRubric';";
                }
                if (!(str2 == ""))
                {
                    str = str + "update SysParmInfo set ParmValue='" + this.RBLLookTestExam.SelectedItem.Value + "' where ParmMemo='IsLookTestExam';";
                }
                else
                {
                    str = str + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('模拟考试成绩查看','" + this.RBLLookTestExam.SelectedItem.Value + "','IsLookTestExam');";
                }
                this.publicFun_0.ExecuteSql(str + ";insert into SysLogInfo(LogDisp,EditUser,EditUserCode) values('编辑系统综合设置参数！','" + this.httpCookie_1.Value + "','" + this.httpCookie_0.Value + "')");
                try
                {
                    FileInfo info = new FileInfo(base.Server.MapPath("../Web.config"));
                    XmlDocument document = new XmlDocument();
                    document.Load(info.FullName);
                    foreach (XmlNode node in document["configuration"]["connectionStrings"])
                    {
                        if (node.Name == "add")
                        {
                            if (node.Attributes.GetNamedItem("name").Value == "SaveMin")
                            {
                                node.Attributes.GetNamedItem("connectionString").Value = this.DDLMinTime.SelectedItem.Value;
                            }
                            if (node.Attributes.GetNamedItem("name").Value == "SaveMax")
                            {
                                node.Attributes.GetNamedItem("connectionString").Value = this.DDLMaxTime.SelectedItem.Value;
                            }
                        }
                    }
                    document.Save(info.FullName);
                }
                catch
                {
                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BSaveTimeTip", @"alert('考场随机自动保存时间设置失败！\n\n请将Web.config文件设置为Everyone用户可修改权限！')", true);
                }
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheckSucc", "alert('综合设置操作成功,建议重新登录或按F5刷新！')", true);
            }
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        protected void DataGridInfo_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            this.DataGridInfo.EditIndex = -1;
            this.method_0();
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        protected void DataGridInfo_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.DataItemIndex == -1)
            {
                this.DataGridInfo.Attributes.Add("oldValue", "#FFFFFF");
                this.DataGridInfo.Attributes.Add("singleValue", "#FFFFFF");
            }
            else
            {
                e.Row.Attributes.Add("onmouseover", "this.bgColor='#F6F5F5'");
                if ((e.Row.DataItemIndex % 2) != 0)
                {
                    e.Row.Attributes.Add("bgcolor", "#FFFFFF");
                    e.Row.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('DataGridInfo').getAttribute('oldValue')");
                }
                else
                {
                    e.Row.Attributes.Add("bgcolor", "#FFFFFF");
                    e.Row.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('DataGridInfo').getAttribute('singleValue')");
                }
            }
            if ((e.Row.RowIndex != -1) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate))))
            {
                TextBox box = (TextBox)e.Row.Cells[0].Controls[0];
                box.Width = 150;
                box.CssClass = "text";
                box.Height = 0x13;
                TextBox box2 = (TextBox)e.Row.Cells[1].FindControl("txtMinValue");
                box2.Width = 60;
                box2.CssClass = "text";
                box2.Height = 0x13;
                TextBox box3 = (TextBox)e.Row.Cells[1].FindControl("txtMaxValue");
                box3.Width = 60;
                box3.CssClass = "text";
                box3.Height = 0x13;
            }
        }

        protected void DataGridInfo_RowEditing(object sender, GridViewEditEventArgs e)
        {
            this.DataGridInfo.EditIndex = e.NewEditIndex;
            this.method_0();
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        protected void DataGridInfo_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                string str = this.DataGridInfo.DataKeys[e.RowIndex]["ID"].ToString();
                string strSql = "";
                TextBox box = (TextBox)this.DataGridInfo.Rows[e.RowIndex].Cells[0].Controls[0];
                TextBox box2 = (TextBox)this.DataGridInfo.Rows[e.RowIndex].Cells[1].FindControl("txtMinValue");
                TextBox box3 = (TextBox)this.DataGridInfo.Rows[e.RowIndex].Cells[1].FindControl("txtMaxValue");
                if (((box2.Text.Trim() == "") || (box3.Text.Trim() == "")) || (box.Text.Trim() == ""))
                {
                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BPower", "alert('所有信息都不可以为空！')", true);
                }
                else
                {
                    strSql = string.Concat(new object[] { "update GradeReule set ReuleName='", this.publicFun_0.CheckString(box.Text), "',MaxValue=", Convert.ToDouble(box3.Text), ",MinValue=", Convert.ToDouble(box2.Text), " where ID=", str });
                    this.publicFun_0.ExecuteSql(strSql);
                    this.DataGridInfo.EditIndex = -1;
                    this.method_0();
                }
            }
            catch
            {
            }
            finally
            {
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
            }
        }

        private void method_0()
        {
            string selectCommandText = "";
            if (!(this.ViewState["UserPower"].ToString() == "Y"))
            {
                selectCommandText = "select * from GradeReule where PaperID=0 and ID=0 order by ID";
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BPower", "alert('系统设置权限未开放！')", true);
            }
            else
            {
                selectCommandText = "select * from GradeReule where PaperID=0 order by ID";
            }
            SqlConnection selectConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            SqlDataAdapter adapter = new SqlDataAdapter(selectCommandText, selectConnection);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet, "GradeReule");
            this.DataGridInfo.DataSource = dataSet.Tables["GradeReule"].DefaultView;
            this.DataGridInfo.DataBind();
            adapter.Dispose();
            dataSet.Dispose();
            selectConnection.Dispose();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_2 = new HttpCookie("ExamUserLevel");
            this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_3 = new HttpCookie("ExamDeptID");
            this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
            if ((this.httpCookie_0 != null) && (this.httpCookie_0.Value != ""))
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                if (!base.IsPostBack)
                {
                    if (this.publicFun_0.ReturnPaperData() == "Yes")
                    {
                        this.ViewState["UserPower"] = this.publicFun_0.GetValues("select ManagSysSet from UserPower where UserCode='" + this.httpCookie_0.Value + "'", "ManagSysSet");
                        this.Page.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString;
                        if (!(this.ViewState["UserPower"].ToString() != "Y"))
                        {
                            this.butDefault.Attributes.Add("onclick", "javascript:{if(confirm('确定设置所有信息吗？')==false) return false;}");
                            this.butBak.Visible = true;
                            this.butBak.Text = "开始备份";
                            this.butBak.Attributes.Add("onclick", "javascript:{if(confirm('确定开始备份数据库吗？')==false) return false;}");
                        }
                        else
                        {
                            this.butDefault.Enabled = false;
                            this.butBak.Enabled = false;
                        }
                        this.method_0();
                        this.DDLMinTime.SelectedIndex = -1;
                        this.DDLMaxTime.SelectedIndex = -1;
                        string connectionString = ConfigurationManager.ConnectionStrings["SaveMin"].ConnectionString;
                        string str30 = ConfigurationManager.ConnectionStrings["SaveMax"].ConnectionString;
                        try
                        {
                            this.DDLMinTime.Items.FindByValue(connectionString).Selected = true;
                            this.DDLMaxTime.Items.FindByValue(str30).Selected = true;
                        }
                        catch
                        {
                            this.DDLMinTime.Items.FindByValue("10").Selected = true;
                            this.DDLMaxTime.Items.FindByValue("30").Selected = true;
                        }
                        string str6 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsTestPaper'", "ParmValue").Trim();
                        string str8 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsCheckDRubric'", "ParmValue").Trim();
                        string str9 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsLookTestExam'", "ParmValue").Trim();
                        string str10 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsCheckBRubric'", "ParmValue").Trim();
                        string str11 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsGradeSort'", "ParmValue").Trim();
                        string str12 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsGradeLook'", "ParmValue").Trim();
                        string str5 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsSetReExam'", "ParmValue").Trim();
                        string str19 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='StudyRubricSum'", "ParmValue").Trim();
                        string str13 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsRegUserCheck'", "ParmValue").Trim();
                        string str14 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsCheckJRubric'", "ParmValue").Trim();
                        string str15 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsStuEdit'", "ParmValue").Trim();
                        string str7 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsGradeStand'", "ParmValue").Trim();
                        string str2 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='BRubricType'", "ParmValue").Trim();
                        string str3 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='GradeReport'", "ParmValue").Trim();
                        string str4 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='RExamPaperType'", "ParmValue").Trim();
                        string str23 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='DayRubric'", "ParmValue").Trim();
                        string str24 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='StudyFen'", "ParmValue").Trim();
                        string str22 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='RubricLoop'", "ParmValue").Trim();
                        string str28 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='RightStudy'", "ParmValue").Trim();
                        if (str28.Trim() == "")
                        {
                            this.txtRightStudySum.Text = "8";
                        }
                        else
                        {
                            this.txtRightStudySum.Text = str28;
                        }
                        string str27 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='SubStrLength'", "ParmValue").Trim();
                        if (str27.Trim() == "")
                        {
                            this.txtSubStrLength.Text = "20";
                        }
                        else
                        {
                            this.txtSubStrLength.Text = str27;
                        }
                        string str26 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='HomeSet'", "ParmValue").Trim();
                        if (str26.Trim() == "")
                        {
                            str26 = "E";
                        }
                        this.RBLHomeSet.Items.FindByValue(str26).Selected = true;
                        string str25 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='DayFen'", "ParmValue").Trim();
                        if (str25.Trim() == "")
                        {
                            str25 = "1";
                        }
                        this.txtDayFen.Text = str25;
                        if (str24.Trim() == "")
                        {
                            str24 = "1";
                        }
                        this.txtStudyFen.Text = str24;
                        if (str23.Trim() == "")
                        {
                            str23 = "N";
                        }
                        if (str22.Trim() == "")
                        {
                            str22 = "N";
                        }
                        this.RBLRubricLoop.Items.FindByValue(str22).Selected = true;
                        this.RBLDayRubric.Items.FindByValue(str23).Selected = true;
                        string str21 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsAllowPrint'", "ParmValue").Trim();
                        if (str21.Trim() == "")
                        {
                            str21 = "Y";
                        }
                        this.RBLAllowPrint.Items.FindByValue(str21).Selected = true;
                        string str20 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsStudyLookOK'", "ParmValue").Trim();
                        if (str20.Trim() == "")
                        {
                            str20 = "Y";
                        }
                        this.RBLStudyOKAn.Items.FindByValue(str20).Selected = true;
                        string str16 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='IsRubricMemo'", "ParmValue").Trim();
                        if (str16.Trim() == "")
                        {
                            str16 = "N";
                        }
                        string str17 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='LookPaperFlag'", "ParmValue").Trim();
                        if (str17.Trim() == "")
                        {
                            str17 = "Y";
                        }
                        string str18 = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='ManagGradeType'", "ParmValue").Trim();
                        if (str18.Trim() == "")
                        {
                            str18 = "Y";
                        }
                        string str = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='SumGradeSort'", "ParmValue").Trim();
                        if (str.Trim() == "")
                        {
                            str = "Y";
                        }
                        if (str2.Trim() == "")
                        {
                            str2 = "Y";
                        }
                        if (str3.Trim() == "")
                        {
                            str3 = "Y";
                        }
                        if (str4.Trim() == "")
                        {
                            str4 = "Y";
                        }
                        if (str15.Trim() == "")
                        {
                            str15 = "Y";
                        }
                        if (str13.Trim() == "")
                        {
                            str13 = "Y";
                        }
                        if (str19 == "")
                        {
                            str19 = "10";
                        }
                        this.txtRubricStudySum.Text = str19;
                        if (str5 == "")
                        {
                            str5 = "N";
                        }
                        if (str7.Trim() == "")
                        {
                            str7 = "Y";
                        }
                        if (str11 == "")
                        {
                            str11 = "Y";
                        }
                        if (str12 == "")
                        {
                            str12 = "Y";
                        }
                        if (str10 == "")
                        {
                            str10 = "Y";
                        }
                        if (str6 == "")
                        {
                            str6 = "N";
                        }
                        if (str8 == "")
                        {
                            str8 = "N";
                        }
                        if (str14 == "")
                        {
                            str14 = "N";
                        }
                        if (str9 == "")
                        {
                            str9 = "N";
                        }
                        this.RBLSumGradeSort.Items.FindByValue(str).Selected = true;
                        this.RBLBRubricType.Items.FindByValue(str2).Selected = true;
                        this.RBLGradeReport.Items.FindByValue(str3).Selected = true;
                        this.RBLRExamPaperType.Items.FindByValue(str4).Selected = true;
                        this.RBLSetReExam.Items.FindByValue(str5).Selected = true;
                        this.RBLTestPaper.Items.FindByValue(str6).Selected = true;
                        this.RBLGradeStand.Items.FindByValue(str7).Selected = true;
                        this.RBLDRubric.Items.FindByValue(str8).Selected = true;
                        this.RBLLookTestExam.Items.FindByValue(str9).Selected = true;
                        this.RBLCRubric.Items.FindByValue(str10).Selected = true;
                        this.RBLGradeSort.Items.FindByValue(str11).Selected = true;
                        this.RBLGradeLook.Items.FindByValue(str12).Selected = true;
                        this.RBLRegCheck.Items.FindByValue(str13).Selected = true;
                        this.RBLJRubric.Items.FindByValue(str14).Selected = true;
                        this.RBLStuEdit.Items.FindByValue(str15).Selected = true;
                        this.RBLOpertionRubricSet.Items.FindByValue(str16).Selected = true;
                        this.RBLLookPaperFlag.Items.FindByValue(str17).Selected = true;
                        this.RBLManagGradeType.Items.FindByValue(str18).Selected = true;
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('此版本暂未授权,请拔打(0)13870606104手机号进行授权！')", true);
                    }
                }
            }
            else
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
        }
    }
}

